import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton } from '../Common/options'
import { OrganizationIdentityLevel } from '../Common/Conversion'

export const ProjectPaymentStat = async ({ url, OptionsEvent, ClientData, Permission }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1, OrderField: 'year@desc,month@desc' },
        get: API_LIST()[`get${url}OC`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission.findIndex(v => v.uuid === 'ce8b44a1-85eb-4d3a-b377-36b3d937f1b7') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.tableName, title: '政府回款名称', hideInSearch: true },
            {
                dataIndex: 'organizationUuid',
                title: '项目名称',
                valueType: 'select',
                valueEnum: await OrganizationIdentityLevel(4),
                rules: true,
                width: 450,
            },
            {
                dataIndex: 'statPaymentAmount',
                title: '实际回款(万元)',
                valueType: 'inputNumber',
                hideInSearch: true,
                rules: true,
                width: 150,
            },
            // {
            //     dataIndex: 'interestAmount',
            //     title: '实际利息',
            //     valueType: 'inputNumber',
            //     hideInSearch: true,
            //     rules: true,
            //     width: 150,
            // },
            {
                dataIndex: 'lateFees',
                title: '滞纳金(万元)',
                valueType: 'inputNumber',
                hideInSearch: true,
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'yearMonth',
                title: '年月',
                valueType: 'Date',
                hideInSearch: true,
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'year',
                title: '年月',
                valueType: 'dateYear',
                width: 150,
                hideInAdded: true,
                hideInModify: true,
                hideInTable: true,
            },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === 'e96d4a3b-e286-4952-b64e-7fabc72dee4b') !== -1 && (
                            <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />
                        ),
                        Permission.findIndex(v => v.uuid === '190df818-7b3d-4883-bbb6-d9868063a88a') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
